﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using XKJ.OAWeb.Infrastructrue;
using XKJ.OAWeb.Models;
using XKJ.OAWeb.Shared;

namespace XKJ.OAWeb.Application
{
    public class LimitsService : ILimitsService
    {
        IBaseRepository<Limits> _limits;

        public LimitsService(IBaseRepository<Limits> limits)
        {
            _limits = limits;
        }
        //显示+查询+分页
        public PageList<Limits> LimitsShow(int Pageindex, int Pagesize, string Details)
        {
            var list = _limits.Show();

            if (!string.IsNullOrEmpty(Details))
            {
                list = list.Where(x => x.Details.Contains(Details));
            }

            PageList<Limits> page = new()
            {
                Total=list.Count(),
                Plist=list.Skip((Pageindex-1)*Pagesize).Take(Pagesize).ToList()
            };

            return page;
        }
    }
}
